#include <stdio.h>
#include <stdlib.h>

#define ARRLEN(array,type) sizeof(array)/sizeof(type)

void  swap(int *a, int *b)
{
	*a = *a +*b;    
	*b = *a - *b;
	*a = *a - *b;

	/*
	 * 若：a = 1, b = 2;
	 * a = a+b;	a = 3,b = 2
	 * b = a-b;	b = 1, a = 3;
	 * a = a-b;	a = 2, b = 1;
	 * */
}


int main()
{
	int i,j,num;
	int array[10] = {1,9,5,6,4,8,1,3,0,2};
	int ac = ARRLEN(array,int);
	for (j = 0 ; j<ac ; j++) { //取值范围：1～ac
		for (i=j+1 ; i<ac ; i++) { //取值范围：j ～ac
			if (array[j] > array[i]) {
				swap(array+j,array+i);
			}
			++num;
		}
		printf("%d\n",array[j]);
	}
	printf("cout number:%d\n",num);


	exit(0);
}

/*
 * 在开始写的时候，有一些盲目，所以导致了一些问题的出现。
 * */
